﻿<UserControl x:Class="VisualTreeInspector.Inspector"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <UserControl.Resources>
        <sdk:HierarchicalDataTemplate x:Key="myTree"
                                      ItemsSource="{Binding Children}">
            <Grid>
                <ToolTipService.ToolTip>
                    <ToolTip>
                        <StackPanel Orientation="Vertical"
                                    Grid.Row="3">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Total Items (for ItemsControl):" />
                                <TextBlock Text="{Binding TotalItems}" />

                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Hashcode:" />
                                <TextBlock Text="{Binding HashCode}" />
                            </StackPanel>
                        </StackPanel>
                    </ToolTip>
                </ToolTipService.ToolTip>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Type}"
                               FontWeight="Bold" />
                    <TextBlock Text=":" Margin="3,0" />
                    <TextBlock Text="{Binding Name,FallbackValue=Nameless}"/>

                </StackPanel>
                <StackPanel Orientation="Horizontal"
                            Grid.Row="2">
                    <TextBlock Text="Total Children:"
                               FontStyle="Italic"></TextBlock>
                    <TextBlock Text="{Binding LocalChildren}" />

                </StackPanel>


            </Grid>
        </sdk:HierarchicalDataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot"
          Background="White">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Button Content="Force Refresh"
                        Margin="5"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Click="RefreshClicked" />
            </Grid>
            <sdk:TreeView ItemTemplate="{StaticResource myTree}"
                          ItemsSource="{Binding}"
                          x:Name="TreeV"
                          Grid.Row="1" />
        </Grid>
    </Grid>
</UserControl>
